3.1199 \(\int (a+b \tan (e+f x)) (c+d \tan (e+f x))^2 \, dx\)

Optimal. Leaf size=89 \[ -\frac{\left (2 a c d+b \left (c^2-d^2\right )\right ) \log (\cos (e+f x))}{f}-x \left (2 b c d-a \left (c^2-d^2\right )\right )+\frac{d (a d+b c) \tan (e+f x)}{f}+\frac{b (c+d \tan (e+f x))^2}{2 f} \]

[Out]

-((2*b*c*d - a*(c^2 - d^2))*x) - ((2*a*c*d + b*(c^2 - d^2))*Log[Cos[e + f*x]])/f + (d*(b*c + a*d)*Tan[e + f*x]
)/f + (b*(c + d*Tan[e + f*x])^2)/(2*f)

________________________________________________________________________________________

Rubi [A]  time = 0.0844995, antiderivative size = 89, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 23, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.13, Rules used = {3528, 3525, 3475} \[ -\frac{\left (2 a c d+b \left (c^2-d^2\right )\right ) \log (\cos (e+f x))}{f}-x \left (2 b c d-a \left (c^2-d^2\right )\right )+\frac{d (a d+b c) \tan (e+f x)}{f}+\frac{b (c+d \tan (e+f x))^2}{2 f} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])^2,x]

[Out]

-((2*b*c*d - a*(c^2 - d^2))*x) - ((2*a*c*d + b*(c^2 - d^2))*Log[Cos[e + f*x]])/f + (d*(b*c + a*d)*Tan[e + f*x]
)/f + (b*(c + d*Tan[e + f*x])^2)/(2*f)

Rule 3528

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(d
*(a + b*Tan[e + f*x])^m)/(f*m), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a+b \tan (e+f x)) (c+d \tan (e+f x))^2 \, dx &=\frac{b (c+d \tan (e+f x))^2}{2 f}+\int (c+d \tan (e+f x)) (a c-b d+(b c+a d) \tan (e+f x)) \, dx\\ &=-\left (2 b c d-a \left (c^2-d^2\right )\right ) x+\frac{d (b c+a d) \tan (e+f x)}{f}+\frac{b (c+d \tan (e+f x))^2}{2 f}+\left (2 a c d+b \left (c^2-d^2\right )\right ) \int \tan (e+f x) \, dx\\ &=-\left (2 b c d-a \left (c^2-d^2\right )\right ) x-\frac{\left (2 a c d+b \left (c^2-d^2\right )\right ) \log (\cos (e+f x))}{f}+\frac{d (b c+a d) \tan (e+f x)}{f}+\frac{b (c+d \tan (e+f x))^2}{2 f}\\ \end{align*}

Mathematica [C]  time = 0.443712, size = 96, normalized size = 1.08 \[ \frac{2 d (a d+2 b c) \tan (e+f x)+(b+i a) (c-i d)^2 \log (\tan (e+f x)+i)+(b-i a) (c+i d)^2 \log (-\tan (e+f x)+i)+b d^2 \tan ^2(e+f x)}{2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[e + f*x])*(c + d*Tan[e + f*x])^2,x]

[Out]

(((-I)*a + b)*(c + I*d)^2*Log[I - Tan[e + f*x]] + (I*a + b)*(c - I*d)^2*Log[I + Tan[e + f*x]] + 2*d*(2*b*c + a
*d)*Tan[e + f*x] + b*d^2*Tan[e + f*x]^2)/(2*f)

________________________________________________________________________________________

Maple [A]  time = 0.005, size = 151, normalized size = 1.7 \begin{align*}{\frac{b{d}^{2} \left ( \tan \left ( fx+e \right ) \right ) ^{2}}{2\,f}}+{\frac{a\tan \left ( fx+e \right ){d}^{2}}{f}}+2\,{\frac{bcd\tan \left ( fx+e \right ) }{f}}+{\frac{a\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) cd}{f}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) b{c}^{2}}{2\,f}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) b{d}^{2}}{2\,f}}+{\frac{a\arctan \left ( \tan \left ( fx+e \right ) \right ){c}^{2}}{f}}-{\frac{a\arctan \left ( \tan \left ( fx+e \right ) \right ){d}^{2}}{f}}-2\,{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ) bcd}{f}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(f*x+e))*(c+d*tan(f*x+e))^2,x)

[Out]

1/2/f*b*d^2*tan(f*x+e)^2+1/f*a*tan(f*x+e)*d^2+2/f*b*c*d*tan(f*x+e)+1/f*a*ln(1+tan(f*x+e)^2)*c*d+1/2/f*ln(1+tan
(f*x+e)^2)*b*c^2-1/2/f*ln(1+tan(f*x+e)^2)*b*d^2+1/f*a*arctan(tan(f*x+e))*c^2-1/f*a*arctan(tan(f*x+e))*d^2-2/f*
arctan(tan(f*x+e))*b*c*d

________________________________________________________________________________________

Maxima [A]  time = 1.78973, size = 123, normalized size = 1.38 \begin{align*} \frac{b d^{2} \tan \left (f x + e\right )^{2} + 2 \,{\left (a c^{2} - 2 \, b c d - a d^{2}\right )}{\left (f x + e\right )} +{\left (b c^{2} + 2 \, a c d - b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 2 \,{\left (2 \, b c d + a d^{2}\right )} \tan \left (f x + e\right )}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

1/2*(b*d^2*tan(f*x + e)^2 + 2*(a*c^2 - 2*b*c*d - a*d^2)*(f*x + e) + (b*c^2 + 2*a*c*d - b*d^2)*log(tan(f*x + e)
^2 + 1) + 2*(2*b*c*d + a*d^2)*tan(f*x + e))/f

________________________________________________________________________________________

Fricas [A]  time = 1.46949, size = 209, normalized size = 2.35 \begin{align*} \frac{b d^{2} \tan \left (f x + e\right )^{2} + 2 \,{\left (a c^{2} - 2 \, b c d - a d^{2}\right )} f x -{\left (b c^{2} + 2 \, a c d - b d^{2}\right )} \log \left (\frac{1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 2 \,{\left (2 \, b c d + a d^{2}\right )} \tan \left (f x + e\right )}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

1/2*(b*d^2*tan(f*x + e)^2 + 2*(a*c^2 - 2*b*c*d - a*d^2)*f*x - (b*c^2 + 2*a*c*d - b*d^2)*log(1/(tan(f*x + e)^2
+ 1)) + 2*(2*b*c*d + a*d^2)*tan(f*x + e))/f

________________________________________________________________________________________

Sympy [A]  time = 0.3717, size = 143, normalized size = 1.61 \begin{align*} \begin{cases} a c^{2} x + \frac{a c d \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - a d^{2} x + \frac{a d^{2} \tan{\left (e + f x \right )}}{f} + \frac{b c^{2} \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - 2 b c d x + \frac{2 b c d \tan{\left (e + f x \right )}}{f} - \frac{b d^{2} \log{\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac{b d^{2} \tan ^{2}{\left (e + f x \right )}}{2 f} & \text{for}\: f \neq 0 \\x \left (a + b \tan{\left (e \right )}\right ) \left (c + d \tan{\left (e \right )}\right )^{2} & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))**2,x)

[Out]

Piecewise((a*c**2*x + a*c*d*log(tan(e + f*x)**2 + 1)/f - a*d**2*x + a*d**2*tan(e + f*x)/f + b*c**2*log(tan(e +
 f*x)**2 + 1)/(2*f) - 2*b*c*d*x + 2*b*c*d*tan(e + f*x)/f - b*d**2*log(tan(e + f*x)**2 + 1)/(2*f) + b*d**2*tan(
e + f*x)**2/(2*f), Ne(f, 0)), (x*(a + b*tan(e))*(c + d*tan(e))**2, True))

________________________________________________________________________________________

Giac [B]  time = 1.91577, size = 1307, normalized size = 14.69 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))*(c+d*tan(f*x+e))^2,x, algorithm="giac")

[Out]

1/2*(2*a*c^2*f*x*tan(f*x)^2*tan(e)^2 - 4*b*c*d*f*x*tan(f*x)^2*tan(e)^2 - 2*a*d^2*f*x*tan(f*x)^2*tan(e)^2 - b*c
^2*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(
f*x)*tan(e) + 1))*tan(f*x)^2*tan(e)^2 - 2*a*c*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e
) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)^2*tan(e)^2 + b*d^2*log(4*(tan(e)^2 + 1
)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(
f*x)^2*tan(e)^2 - 4*a*c^2*f*x*tan(f*x)*tan(e) + 8*b*c*d*f*x*tan(f*x)*tan(e) + 4*a*d^2*f*x*tan(f*x)*tan(e) + b*
d^2*tan(f*x)^2*tan(e)^2 + 2*b*c^2*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2
*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)*tan(e) + 4*a*c*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*ta
n(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1))*tan(f*x)*tan(e) - 2*
b*d^2*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*t
an(f*x)*tan(e) + 1))*tan(f*x)*tan(e) - 4*b*c*d*tan(f*x)^2*tan(e) - 2*a*d^2*tan(f*x)^2*tan(e) - 4*b*c*d*tan(f*x
)*tan(e)^2 - 2*a*d^2*tan(f*x)*tan(e)^2 + 2*a*c^2*f*x - 4*b*c*d*f*x - 2*a*d^2*f*x + b*d^2*tan(f*x)^2 + b*d^2*ta
n(e)^2 - b*c^2*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x
)^2 - 2*tan(f*x)*tan(e) + 1)) - 2*a*c*d*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*tan(f*x)^3*tan(e) + tan(
f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1)) + b*d^2*log(4*(tan(e)^2 + 1)/(tan(f*x)^4*tan(e)^2 - 2*t
an(f*x)^3*tan(e) + tan(f*x)^2*tan(e)^2 + tan(f*x)^2 - 2*tan(f*x)*tan(e) + 1)) + 4*b*c*d*tan(f*x) + 2*a*d^2*tan
(f*x) + 4*b*c*d*tan(e) + 2*a*d^2*tan(e) + b*d^2)/(f*tan(f*x)^2*tan(e)^2 - 2*f*tan(f*x)*tan(e) + f)